package com.tarena.dang.actions.user;

import com.tarena.dang.actions.BaseAction;
import com.tarena.dang.pojos.User;
import com.tarena.dang.services.UserService;
import com.tarena.dang.services.impl.UserServiceImpl;
import com.tarena.dang.utils.Constant;

public class CheckEmailVerifyCodeAction extends BaseAction {
	private String code;

	public String execute() {
		UserService service = new UserServiceImpl();
		User user = (User) session.get(Constant.USER);
		try {
			if (service.checkEmailCode(user, code)) {
				return "success";
			} else {
				return "fail";
			}
		} catch (Exception e) {
			e.printStackTrace();
			return "fail";
		}
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getCode() {
		return code;
	}
}
